package com.fenghuajueli.idiomppp.ui.fragment.pinpin;


import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.fenghuajueli.idiomppp.R;
import com.fenghuajueli.idiomppp.base.JumpActivityUtils;
import com.fenghuajueli.idiomppp.config.BizCallBack;
import com.fenghuajueli.idiomppp.ui.guessidiom.IdiomGuessSelectPassActivity;
import com.fenghuajueli.idiomppp.ui.idiompin.IdiomJieLongSelectPassActivity;
import com.fenghuajueli.idiomppp.ui.idiompin.IdiomSelectPassActivity;
import com.fenghuajueli.idiomppp.ui.idiompin.IdiomXiaoXiaoSelectPassActivity;
import com.fenghuajueli.libbasecoreui.mvp.BaseFragment;

/**
 * 成语拼拼拼界面
 */
public class IdiomPinFragment extends BaseFragment {

    private View contentView;

    private IdiomPinFragmentAgeint ageint;

    private ViewGroup adContainer;

    public static BizCallBack mCallback;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        contentView = inflater.inflate(R.layout.fragment_idiom_pin, container, false);
        adContainer = contentView.findViewById(R.id.ad_container);
        if(ageint!=null){
            ageint.ad(adContainer);
        }
        return contentView;
    }

    public void setAgeint(IdiomPinFragmentAgeint ageint) {
        this.ageint = ageint;
    }

    public static IdiomPinFragment newInstance() {

        Bundle args = new Bundle();

        IdiomPinFragment fragment = new IdiomPinFragment();
        fragment.setArguments(args);
        return fragment;
    }

    public void OnClick(View view) {

        int id = view.getId();
        if (id == R.id.ivIdiomPin) {
            if(mCallback!=null){
                if( mCallback.onBiz(0)){
                    JumpActivityUtils.goNormalActivity(getContext(), IdiomSelectPassActivity.class);
                }
            }else {
                JumpActivityUtils.goNormalActivity(getContext(), IdiomSelectPassActivity.class);
            }
        } else if (id == R.id.ivIdiomJieLong) {

            if(mCallback!=null){
                if( mCallback.onBiz(1)){
                    JumpActivityUtils.goNormalActivity(getContext(), IdiomJieLongSelectPassActivity.class);
                }
            }else {
                JumpActivityUtils.goNormalActivity(getContext(), IdiomJieLongSelectPassActivity.class);
            }
        } else if (id == R.id.ivIdiomXiao) {
            if(mCallback!=null){
                if( mCallback.onBiz(2)){
                    JumpActivityUtils.goNormalActivity(getContext(), IdiomXiaoXiaoSelectPassActivity.class);
                }
            }else {
                JumpActivityUtils.goNormalActivity(getContext(), IdiomXiaoXiaoSelectPassActivity.class);
            }
        } else if (id == R.id.ivIdiomPicture) {
            if(mCallback!=null){
                if( mCallback.onBiz(3)){
                    JumpActivityUtils.goNormalActivity(getContext(), IdiomXiaoXiaoSelectPassActivity.class);
                }
            }else {
                JumpActivityUtils.goNormalActivity(getContext(), IdiomGuessSelectPassActivity.class);
            }
        }
    }
    public interface IdiomPinFragmentAgeint{
        void ad(ViewGroup adContainer);
    }

}
